<template>
	
	<view>
		<u-form class="info1">
			<u-form-item label="姓名:"><u-input disabled = "true" v-model="form.coachName" /></u-form-item>
			<u-form-item label="年龄:"><u-input disabled = "true" v-model="form.coachAge" /></u-form-item>
			<u-form-item label="详细介绍:"><u-input disabled = "true" v-model="form.coachDetail" /></u-form-item>
			<u-form-item label="性别:"><u-input disabled = "true" v-model="form.coachSex" /></u-form-item>
			<u-form-item label="好评数:"><u-input disabled = "true" v-model="form.positive" /></u-form-item>
			<u-form-item label="电话:"><u-input disabled = "true" v-model="form.coachTel" /></u-form-item>
			<u-form-item label="是否官方认证:"><u-input disabled = "true" v-model="isoffical" /></u-form-item>
			<u-form-item label="是否场馆认证:"><u-input disabled = "true" v-model="isvenue" /></u-form-item>
		</u-form>
		<u-button type="info" @click="buy">购买私教课</u-button>
		<u-button @click="back1">返回</u-button>
		<!-- 输入购买数量的模态框 -->
		<u-modal v-model="show" title="请输入购买的小时数(整数)" @confirm="buySome" @cancle="no1" show-cancel-button="true">
			<input type="text" v-model="hour"></input>
		</u-modal>
	</view>
</template>
<script>
	export default {
	    data() {
	        return {
				id: '',
				isoffical:'',
				isvenue:'',
				form:{
					coachId: '',
					positive: '',
					coachAge: '',
					coachSex: '',
					birthday: '',
					coachTel: '',
					coachName: '',
					coachDetail: '',
					isOffical: '',
					isVenue: ''
				},
				form2:{
					coachId:'',
					bak1:''
				},
				show: false,
				hour: 1,
				map:{}
	        }
	    },
		onShow(){
			this.$u.api.findOneCoach(this.id).then(res => {
				this.form = res.data
				if(this.form.isOffical == true || form.isOffical == 1){
					this.isoffical = '是'
				}else{
					this.isoffical = '否'
				}
				
				if(this.form.isVenue == true || form.isVenue == 1){
					this.isvenue = '是'
				}else{
					this.isvenue = '否'
				}
				
			})
		},
		onLoad: function(Option){
			this.id = Option.id
		},
		methods: {
			back1(){
				uni.switchTab({
				    url: '/pages/tabbar/life/life'
				});
			},
			buy(){
				this.show = true;
			},
			buySome(){
				this.form2.coachId = this.form.coachId
				this.form2.bak1 = (this.form.hourMoney * this.hour) +""
				this.$u.api.privateCourseResquest(this.form2).then(res => {
					if(res.status==200){
						res.msg = '成功,等待联系'
					}
					let str = res.msg;
					    uni.showToast({
					       title: str,
					       icon: "primary",
					       success: () => {
							   
					       }
					     });
				})
			},
			no1(){
				this.show = false;
			}
		}
	}
</script>
<style>
	.info1{
		margin-left: 20rpx;
	}
</style>